﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet_Controller : MonoBehaviour
{
    //定义子弹飞行速度
    public float bulletSpeed = 50;
    public Monster_Group targets;
    public GameObject target;
    private Vector3 dir;
    void Start() 
    {
        targets = FindObjectOfType<Monster_Group>();
    }
    void Update()
    {
        target = targets.monster;
        dir = target.transform.position - transform.position;
        transform.LookAt(target.transform.position);
        transform.Translate( dir* bulletSpeed * Time.deltaTime,Space.World);//子弹朝着射出的方向飞行
        GameObject.Destroy(this.gameObject,1);
    }
}
